home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
dalla rivista
/
host contacted
/
imengv3.41p2.lha
/
ImEngV3.41p2
/
Extra
/
ARexx
/
IndexClone.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-01-06
|
2KB
|
63 lines
/*
** $VER: IndexClone.rexx 1.03 (4/1 Stockholm/Sweden)
** Copyright © 1997 by Patrik M Nydensten
**
** Clones files with an index number.
** The new name will be the new specified basename with the same
** index number as the original files.
**
** Usage: <new_basename> <first_index_file> <last_index_file>
*/
options results
parse arg newbase files
if pos('"',files) = 0 then parse var files file1 file2
else parse var files '"'file1'"' '"'file2'"'
fix = strip(get_ext(file1)) ; lix = strip(get_ext(file2))
if ((~datatype(fix,'N'))|(~datatype(lix,'N'))) then errorx('Error: Bad index number in file name.')
fi = min(fix,lix) ; li = max(fix,lix)
if newbase = '' then errorx('Error: Bad new basename')
do i = fi to li
new_file = get_path(file1)||newbase'.'right(i,4,'0')
old_file = get_base(file1)'.'right(i,4,'0')
if exists(old_file) then do
if ~exists(new_file) then do
address 'COMMAND' 'copy' '"'old_file'"' '"'new_file'"'
end
else say 'Error: File already exists. "'old_file'".'
end
else say 'Error: Could not locate file "'old_file'".'
end
exit
/* --[ proc ]--------------------------- */
errorx:
parse arg text
say text
exit 5
return 0
get_ext:
parse arg get_ext_in
if lastpos('.',get_ext_in) ~= 0 then get_ext_back = substr(get_ext_in,1+lastpos('.',get_ext_in))
else get_ext_back = ''
return get_ext_back
get_base:
parse arg get_base_in
if lastpos('.',get_base_in) ~= 0 then get_base_back = substr(get_base_in,1,lastpos('.',get_base_in)-1)
else get_base_back = get_base_in
return get_base_back
get_path:
parse arg get_path_in
if lastpos('/',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos('/',get_path_in))
else if lastpos(':',get_path_in) ~= 0 then get_path_back = substr(get_path_in,1,lastpos(':',get_path_in))
else get_path_back = ''
return get_path_back